﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace iTunesNowPlaying
{
    public partial class frmOptions : Form
    {
        Settings m_settings;
        public frmOptions(Settings settings)
        {
            InitializeComponent();
            m_settings = settings;
            ApplySettings();
        }

        private void ApplySettings()
        {
            chbxAlbum.Checked = m_settings.ShowAlbum;
            chbxArtist.Checked = m_settings.ShowArtist;
            chbxTitle.Checked = m_settings.ShowTitle;
            txbxPrefix.Text = m_settings.Prefix;
            UpdatePreview();
        }

        private void txbxPrefix_TextChanged(object sender, EventArgs e)
        {
            UpdatePreview();
        }

        private void UpdatePreview()
        {
            lblPreviewText.Text = m_settings.GetText(chbxAlbum.Checked, chbxArtist.Checked,
                                    chbxTitle.Checked, txbxPrefix.Text);
        }

        private void chbxArtist_CheckedChanged(object sender, EventArgs e)
        {
            UpdatePreview();
        }

        private void chbxTitle_CheckedChanged(object sender, EventArgs e)
        {
            UpdatePreview();
        }

        private void chbxAlbum_CheckedChanged(object sender, EventArgs e)
        {
            UpdatePreview();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            m_settings.Prefix = txbxPrefix.Text;
            m_settings.ShowAlbum = chbxAlbum.Checked;
            m_settings.ShowArtist = chbxArtist.Checked;
            m_settings.ShowTitle = chbxTitle.Checked;
            this.Close();
        }
    }
}
